package com.ler.yrmall.order.conf;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @author Leron
 * @version 1.0
 * @date 2021/2/1 12:26
 */

@Configuration
public class MyThreadPoolConf {
    @Bean
    public ThreadPoolExecutor threadPoolExecutor(MyThreadProperties properties) {
        return new ThreadPoolExecutor(
                properties.getCoreSize(),
                properties.getMaxSize(),
                properties.getKeepActiveTime(),
                TimeUnit.SECONDS,new LinkedBlockingDeque<>(100000),
                new ThreadPoolExecutor.AbortPolicy());
    }

}
